<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #fa {
            width: 600px;
            height: 600px;
            border: 1px solid black;
            margin: 200px auto;
        }

        #fa>div {
            width: 33%;
            height: 33%;
            border: 1px solid black;
            float: left;
            line-height: 200px;
            text-align: center;
            font-size: 25px;
            font-weight: bold;
        }

        #start {
            cursor: pointer;
            background-color: pink;
        }
    </style>
</head>

<body>
    <div id="fa">
        <div class="option">玩具熊一只</div>
        <div class="option">华为Mate50一台</div>
        <div class="option">豆豆鞋一双</div>
        <div class="option">红烧牛肉面一箱</div>
        <div id="start">开始抽奖</div>
        <div class="option">老干妈一瓶</div>
        <div class="option">飞旺一包</div>
        <div class="option">再来一次</div>
        <div class="option">AD钙一箱</div>
    </div>

</body>
<script>
    let but = document.getElementById('start');
    let options = document.getElementsByClassName('option');
    let timer = null;
    but.onclick = function () {
        let num = 0;  //设置一个初始值
        if (timer == null) {  //触发定时器
            timer = setInterval(() => {
                num++;
                let ran = Math.round(Math.random() * (7 - 0) + 0);  //随机获取一个0-7的数
                for (let i = 0; i < options.length; i++) {
                    options[i].style.backgroundColor = '#fff';  //给选中的元素添加样式
                }
                options[ran].style.backgroundColor = 'orange';
                if (num >= 50) {  //给定时器添加有效时间
                    clearInterval(timer);
                    timer = null;
                }
            }, 100);
        }
    }
</script>

</html>